package day6Exer;

/*
* 抽象父类 animal
* */
public abstract class Animal {

    public static void main(String[] args) {
        Cat cat = new Cat();

        cat.setName("阿花");
        cat.setAge(3);

        cat.voice();
        cat.eat();

    }
    //名称
    private String name;

    //年龄
    private int age;


    //抽象方法吃
    public abstract void eat();

    //抽象方法叫
    public abstract void voice();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}

class Dog extends Animal{

    @Override
    public void eat() {
        System.out.println("名称为"+getName()+",的狗在吃酱骨头");
    }

    @Override
    public void voice() {
        System.out.println("名称为"+getName()+",年龄:"+getAge()+"在嚎叫");
    }
}
class Cat extends Animal{

    @Override
    public void eat() {
        System.out.println("名称为"+getName()+",的猫在炫老鼠");
    }

    @Override
    public void voice() {
        System.out.println("名称为"+getName()+",年龄:"+getAge()+"在学喵叫");
    }
}
